#include <iostream>
using namespace std;

int find_replace_str(char str[], const char find_str[],const char replace_str[]){
	int count = 0 ;
	int loc = 0;
	char *temp = new char[1000]; 
	for(int i = 0;str[i] != '\0';i++)
		if(str[i] == find_str[loc]){
			loc++;
			if(find_str[loc] == '\0'){
				for(int j = 0;j < loc;j++)
					str[i - loc + 1 + j] = replace_str[j];
				loc = 0;
				count++;
			}
		}else{
			if(loc != 0){
				loc = 0;
				i--;
			}
		}
		return count;
}

void main(){
	char s[] = "asasdaasdwertyaaaassasd";
	char find[] = "asd";
	char replace[] = "wer";
	int r = find_replace_str(s,find,replace);
	cout << r << " " << s << endl;
	system("pause");
}